package view;

import java.awt.BorderLayout;
import java.io.IOException;
import transfer.ChessData;
import chess.Board;
import chessman.Chessman;
import client.Client;

public class PlayGameView extends ChessOnlineView{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2991508341973480572L;
	private Board board;
	private ChatForm chatForm;
	public PlayGameView(Client mainScreen, int id) {
		super(mainScreen);
		try {
			board = new Board(mainScreen);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		chatForm = new ChatForm(mainScreen,id);
	//	chatForm.loadTeam(id);
	//	chatForm.setTeamName(id); // set name
		board.getMouseListener().setTeam(id);
		this.setLayout(new BorderLayout());
		
		this.add(board,BorderLayout.CENTER);
		this.add(chatForm,BorderLayout.LINE_END);
	}
	public void setCurrentTurn(int turn) {
		board.getMouseListener().setTurn(turn);
	}

	public void refreshBoard(ChessData data) {
		board.setArrayChess(data.getArrayChess());
		board.refreshBoard();
	}

	public void refreshBoard(Chessman[] data) {
		board.setArrayChess(data);
		board.refreshBoard();
	}
	public void appendChatString(String s){
		chatForm.appendChatString(s);
	}
	public void refreshLabelTurn (int turn){
		if(turn == board.getMouseListener().getTeam()){
			chatForm.getLblTurn().setText("Your Turn");
		}
		else{
			chatForm.getLblTurn().setText("Opponent Turn");
		}
	}
	
}
